import WebStorageCache from 'web-storage-cache'
type CacheType = 'sessionStorage' | 'localStorage'
export  const CACHE_KEY={
    ROLE_ROUTERS: 'roleRouters',
  USER: 'user',
  // 系统设置
  IS_DARK: 'isDark',
  LANG: 'lang',
  THEME: 'theme',
  LAYOUT: 'layout',
  DICT_CACHE: 'dictCache',
  // 登录表单
  LoginForm: 'loginForm',
  TenantId: 'tenantId'

}
export const useCache = (type: CacheType = 'localStorage') => {
    const wsCache:WebStorageCache = new WebStorageCache({
        storage: type,
    })
    return {
        wsCache
    }
}
export const deleteUserCache = () => {
    const {wsCache} = useCache()
    wsCache.delete(CACHE_KEY.USER)
    wsCache.delete(CACHE_KEY.ROLE_ROUTERS)
}